import java.net.ServerSocket;
import java.net.Socket;
import java.io.*;

public class ObslugaDB extends ConnectionReader implements Runnable{
	private ConnectionWriter DBwriter;
	
	public ObslugaDB(Socket s) throws IOException {
		super(new Connection(s));
		DBwriter = new ConnectionWriter(new Connection(s));
	}
	
	@Override
	public void handleMessage(Message message) {
		System.out.println("Otrzymalem wiadomosc od bazy danych o tresci: "+message.getCommand()) ;
		
	}
		
	public void run() {
		System.out.println("running kurwa");
		DBwriter.start();
			while(true) {			
					Message m = getMessage();
					if(m.getType() != Message.AWARIA) {
						this.handleMessage(m);
					}
			}
		}
	}
	